const arr = [1, 3, 5, 3, 2, 1, 4, 6, 6, 8, 2, 9, 7]

const callbackFn = (arr) => {
  return arr.filter(
    (item, index, array) =>
      array.indexOf(item) !== array.lastIndexOf(item) &&
      array.indexOf(item) === index
  )
}

console.log(callbackFn(arr))

const chunk = (arr, size) => {
  const result = []

  for (let i = 0; i < arr.length; i+=size) {
    result.push(arr.slice(i, i + size))
  }

  return result
}

console.log(chunk(arr, 3))
